package com.developlibrary.search;

import java.util.*;
import java.util.Map;
import java.util.Arrays;

public class WLCN_IndexQuery implements Query{
	private Map condition;

	public void setCondition(Map c){
		this.condition = c;
	
	}

	private void testLoop(){
		Iterator iter = condition.entrySet().iterator();
		while(iter.hasNext()){
			Map.Entry entry = (Map.Entry)iter.next();
			String key = entry.getKey().toString();
			//String val = entry.getValue().toString();
			Object obj = entry.getValue();
			String val = "";
			if(obj instanceof String[]){
				String[] strs = (String[])obj;
				val = Arrays.toString(strs);
			}else{
				val = obj.toString();
			}

			System.out.println(val);
		}

	
	}

	public String createSentence(){
		
		return "";
	}

	public String createSentence(String[] list){
		Object v;
		String u="";
	
		for(int i=0;i<list.length;i++){
			if(condition.get(list[i])!=null){
				String[] values = (String[])condition.get(list[i]);
				u+=list[i]+"="+Arrays.toString(values);
			}
		}

		/*

		for(Object k:this.condition.keySet()){
			String[] obj = (String[])this.condition.get(k);
			u+=k+"="+Arrays.toString(obj);

			/*
			String val = "";
			if(obj instanceof String[]){
			
				String[] strs = (String[])obj;
				val = Arrays.toString(strs);
			}else{
				val = obj.toString();
			}

			System.out.println(val);
			*/

		/*
		}
		*/

		return u;
	}

	public String get(String[] list){
		String s = this.createSentence(list);
		return s;
	}

}
